package www.sharetime.weshare.view;

import android.content.Context;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;

import java.util.List;

import www.sharetime.weshare.R;
import www.sharetime.weshare.tag.TagViewGroup;
import www.sharetime.weshare.tag.model.TagGroupModel;
import www.sharetime.weshare.tag.views.TagImageView;

/**
 * Created by Administrator on 2017/4/15.
 */

public class BLBeautifyImageView extends FrameLayout {
    private Context mContext;
    private TagImageView mTagGroupLayout;

    public BLBeautifyImageView(@NonNull Context context) {
        this(context, null);
    }

    public BLBeautifyImageView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public BLBeautifyImageView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        init();
    }

    private void init() {
        View rootView = LayoutInflater.from(mContext).inflate(R.layout.bl_beautify_image_view, this, true);
        mTagGroupLayout = (TagImageView) rootView.findViewById(R.id.bl_tag_image_view);
    }

    public void setImage(String path) {
        mTagGroupLayout.setImageUrl(path);
    }

    /**********************************TagImageView相关*********************************/
    public void addTagGroup(TagGroupModel model, TagViewGroup.OnTagGroupClickListener listener, boolean editMode) {
        mTagGroupLayout.setEditMode(editMode);
        mTagGroupLayout.addTagGroup(model, listener);
    }

    public void removeTagGroup(TagViewGroup tagViewGroup) {
        mTagGroupLayout.removeTagGroup(tagViewGroup);
    }

    public void removeTagGroupByTagGroupModel(TagGroupModel tagGroupModel) {
        mTagGroupLayout.removeTagGroupByTagGroupModel(tagGroupModel);
    }

    public List<TagGroupModel> getTagGroupModelList() {
        return mTagGroupLayout.getTagGroupModelList();
    }

    public TagGroupModel getTagGroupModel(TagViewGroup group) {
        return mTagGroupLayout.getTagGroupModel(group);
    }

    public void setTagModelList(List<TagGroupModel> tagGroupList) {
        mTagGroupLayout.setTagList(tagGroupList);
    }

    public TagImageView getTagImageView() {
        return mTagGroupLayout;
    }

}
